<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * CodeIgniter
 *
 * An open source application development framework for PHP 5.1.6 or newer
 *
 * @package		CodeIgniter
 * @author		ExpressionEngine Dev Team
 * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc.
 * @license		http://codeigniter.com/user_guide/license.html
 * @link		http://codeigniter.com
 * @since		Version 1.0
 * @filesource
 */

// ------------------------------------------------------------------------

/**
 * Loader Class
 *
 * Loads views and files
 *
 * @package		CodeIgniter
 * @subpackage	Libraries
 * @author		ExpressionEngine Dev Team
 * @category	Loader
 * @link		http://codeigniter.com/user_guide/libraries/loader.html
 */
class MY_Loader  extends CI_Loader{

	/**
	 * Constructor
	 *
	 * Sets the path to the view files and gets the initial output buffering level
	 */
	public function __construct()
	{
		
		parent::__construct();
		log_message('debug', "Loader Class Initialized");
	}
	//模板调用
	public function template($name, $vars = array(), $return = FALSE) 
	{
		
		$template_dir =config_item('template_dir');

		if(empty($template_dir))
		{
			$template_dir='default';
		}
		if(strpos($name,'/')) {
			$tpl = $name;
		} else {
			$tpl = "template/$template_dir/$name";
		}
		$objfile = APPPATH.'./views/tpl_cache/'.str_replace('/','_',$tpl).'.php';
 
		//if(!file_exists($objfile))
		{
			$CI =& get_instance();
			$CI->load->library('template');
			$CI->template->parse_template($tpl);
		}
		return $this->view('tpl_cache/'.str_replace('/','_',$tpl),$vars,$return);
	}

	 
}

/* End of file Loader.php */
/* Location: ./system/core/Loader.php */